/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.InOut
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-29
 * @time 下午3:47:37
 */
package com.ssh.web.admin;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.entity.FcarAplly;
import com.ssh.model.pdata.FInOutApplyMPData;
import com.ssh.ser.inout.FVehicleMSerI;

/**
 * @author jack
 * @desc 长期出入地方车申请action
 * @property FInOutApplyMPData FVehicleMSerI
 */
public class FVApplyMAction extends ActionSupport {
	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private String driverId;
	private String fcarCarid;
	private String idFvehicleApply;

	public String getIdFvehicleApply() {
		return idFvehicleApply;
	}

	public void setIdFvehicleApply(String idFvehicleApply) {
		this.idFvehicleApply = idFvehicleApply;
	}

	private List<FInOutApplyMPData> frequentlyIOList;
	private FVehicleMSerI frequentlyIOMSerI;

    /**处理长期出入地方车申请*/
	public String dealFIOApplyByCId() {
		try {
			FcarAplly fcarAplly = new FcarAplly();
			fcarAplly.setFcarCarid(fcarCarid);
			fcarAplly.setApplyResult((short) 1);
			frequentlyIOMSerI.dealFIOApplyByCardId(fcarAplly);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "ok";
	}

	   /**同意长期出入地方车申请*/
	public String agree() {
		try {
			int id = Integer.parseInt(idFvehicleApply);
			FcarAplly fcarAplly = frequentlyIOMSerI.queryFIOApplyById(id);
			fcarAplly.setApplyResult((short) 2);
			frequentlyIOMSerI.dealFIOApplyByCardId(fcarAplly);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "agree";
	}
	   /**拒绝长期出入地方车申请*/
	public String disagree() {
		try {
			int id = Integer.parseInt(idFvehicleApply);
			FcarAplly fcarAplly = frequentlyIOMSerI.queryFIOApplyById(id);
			fcarAplly.setApplyResult((short) 1);
			frequentlyIOMSerI.dealFIOApplyByCardId(fcarAplly);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "disagree";
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		//Action默认查看所有信息
		return viewAllFIOApply();
	}

	/**
	 * @return the driverId
	 */
	public String getDriverId() {
		return driverId;
	}

	/**
	 * @return the fcarCarid
	 */
	public String getFcarCarid() {
		return fcarCarid;
	}


	/**
	 * @return the frequentlyIOList
	 */
	public List<FInOutApplyMPData> getFrequentlyIOList() {
		return frequentlyIOList;
	}


	/**
	 * @return the frequentlyIOMSerI
	 */
	public FVehicleMSerI getFrequentlyIOMSerI() {
		return frequentlyIOMSerI;
	}

	public String getFVehicleApply() {
		// TODO Auto-generated method stub
		try {
			frequentlyIOList = frequentlyIOMSerI.getFIOApplyByState((short)0);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}


    /**
	 * @param driverId
	 *            the driverId to set
	 */
	public void setDriverId(String driverId) {
		this.driverId = driverId;
	}

	/**
	 * @param fcarCarid
	 *            the fcarCarid to set
	 */
	public void setFcarCarid(String fcarCarid) {
		this.fcarCarid = fcarCarid;
	}

	/**
	 * @param frequentlyIOList the frequentlyIOList to set
	 */
	public void setFrequentlyIOList(List<FInOutApplyMPData> frequentlyIOList) {
		this.frequentlyIOList = frequentlyIOList;
	}

	/**
	 * @param frequentlyIOMSerI the frequentlyIOMSerI to set
	 */
	public void setFrequentlyIOMSerI(FVehicleMSerI frequentlyIOMSerI) {
		this.frequentlyIOMSerI = frequentlyIOMSerI;
	}

	/**按状态查看长期出入地方车的申请*/
	public String viewAllFIOApply(){
		try {
			frequentlyIOList = frequentlyIOMSerI.getFIOApplyByState((short)0);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}


}
